package com.thomasbrault.utils 
{	/**	 * @author thomasbrault	 */	public class DisplayObjectUtils 
	{
		public static function resize ( $target : *, $width : Number, $height : Number, $mode : String, $refWidth : Number = NaN, $refHeight : Number = NaN ) : void
		{
			
			if ( isNaN($refWidth) )
				$refWidth = $target.width;
			
			if ( isNaN($refHeight) )
				$refHeight = $target.height;
			
			var scale : Number;
			
			switch ( $mode )
			{
				case 'crop':
					scale = Math.max ( $width/$refWidth, $height/$refHeight );
				break;
				case 'fit':
					scale = Math.min ( $width/$refWidth, $height/$refHeight );
				break;
				default:
					throw new Error('AdvancedLoader error : this method does not exist');
				break;
			}
			
			$target.scaleX = $target.scaleY = scale;
			
		}	}}